PROP_UPPER_STEPPER_SENSITIVITY,
PROP_SHOW_FILL_LEVEL,
PROP_RESTRICT_TO_FILL_LEVEL,
- PROP_FILL_LEVEL
+ PROP_FILL_LEVEL,
+ PROP_ROUND_DIGITS
};
enum {
* @returns: %TRUE to prevent other handlers from being invoked for the
* signal, %FALSE to propagate the signal further
*
- * The ::change-value signal is emitted when a scroll action is
+ * The #GtkRange::change-value signal is emitted when a scroll action is
* performed on a range. It allows an application to determine the
* type of scroll event that occurred and the resultant new value.
* The application can handle the event itself and return %TRUE to
* reached.
*
* The value parameter is unrounded. An application that overrides
- * the ::change-value signal is responsible for clamping the value to
- * the desired number of decimal digits; the default GTK+ handler
- * clamps the value based on @range->round_digits.
+ * the GtkRange::change-value signal is responsible for clamping the
+ * value to the desired number of decimal digits; the default GTK+
+ * handler clamps the value based on #GtkRange:round-digits.
*
* It is not possible to use delayed update policies in an overridden
- * ::change-value handler.
+ * #GtkRange::change-value handler.
*
* Since: 2.6
*/
G_MAXDOUBLE,
GTK_PARAM_READWRITE));
+ /**
+ * GtkRange:round-digits:
+ *
+ * The number of digits to round the value to when
+ * it changes, or -1. See #GtkRange::change-value.
+ *
+ * Since: 2.24
+ */
+ g_object_class_install_property (gobject_class,
+ PROP_ROUND_DIGITS,
+ g_param_spec_int ("round-digits",
+ P_("Round Digits"),
+ P_("The number of widgets to round the value to."),
+ -1,
+ G_MAXINT,
+ -1,
+ GTK_PARAM_READWRITE));
+
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("slider-width",
P_("Slider Width"),
case PROP_FILL_LEVEL:
gtk_range_set_fill_level (range, g_value_get_double (value));
break;
+ case PROP_ROUND_DIGITS:
+ gtk_range_set_round_digits (range, g_value_get_int (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_FILL_LEVEL:
g_value_set_double (value, gtk_range_get_fill_level (range));
break;
+ case PROP_ROUND_DIGITS:
+ g_value_set_int (value, gtk_range_get_round_digits (range));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
181, force_repaint,
range, NULL);
}
-
+
/* Note that we don't round off to priv->round_digits here.
* that's because it's really broken to change a value
* in response to a change signal on that value; round_digits
return priv->n_marks;
}
+/**
+ * gtk_range_set_round_digits:
+ * @range: a #GtkRange
+ * @round_digits: the precision in digits, or -1
+ *
+ * Sets the number of digits to round the value to when
+ * it changes. See #GtkRange::change-value.
+ *
+ * Since: 2.24
+ */
void
-_gtk_range_set_round_digits (GtkRange *range,
- gint round_digits)
+gtk_range_set_round_digits (GtkRange *range,
+ gint round_digits)
{
+ g_return_if_fail (GTK_IS_RANGE (range));
+ g_return_if_fail (round_digits >= -1);
+
range->priv->round_digits = round_digits;
+
+ g_object_notify (G_OBJECT (range), "round-digits");
+}
+
+/**
+ * gtk_range_get_round_digits:
+ * @range: a #GtkRange
+ *
+ * Gets the number of digits to round the value to when
+ * it changes. See #GtkRange::change-value.
+ *
+ * Return value: the number of digits to round to
+ *
+ * Since: 2.24
+ */
+gint
+gtk_range_get_round_digits (GtkRange *range)
+{
+ g_return_val_if_fail (GTK_IS_RANGE (range), -1);
+
+ return range->priv->round_digits;
}
void
priv->draw_value = TRUE;
priv->value_pos = GTK_POS_TOP;
priv->digits = 1;
- _gtk_range_set_round_digits (range, priv->digits);
+ gtk_range_set_round_digits (range, priv->digits);
gtk_scale_orientation_notify (range, NULL);
g_signal_connect (scale, "notify::orientation",
{
priv->digits = digits;
if (priv->draw_value)
- _gtk_range_set_round_digits (range, digits);
+ gtk_range_set_round_digits (range, digits);
_gtk_scale_clear_layout (scale);
gtk_widget_queue_resize (GTK_WIDGET (scale));
{
priv->draw_value = draw_value;
if (draw_value)
- _gtk_range_set_round_digits (GTK_RANGE (scale), priv->digits);
+ gtk_range_set_round_digits (GTK_RANGE (scale), priv->digits);
else
- _gtk_range_set_round_digits (GTK_RANGE (scale), -1);
+ gtk_range_set_round_digits (GTK_RANGE (scale), -1);
_gtk_scale_clear_layout (scale);